package ch.justdoit.andriodrpncalc.model.command;

import ch.justdoit.andriodrpncalc.model.CalcNumber;
import ch.justdoit.andriodrpncalc.model.Model;

public class PeekCommand extends BaseCommand {

	public PeekCommand(Model _model) {
		super(_model);
		mCommandName = "peek";
	}

	@Override
	public boolean doit() {
		int pos = mModel.getCursorPosition();
		if (pos+1 <= mModel.stack.size()) {
			CalcNumber peekNumberInStack = mModel.stack.PeekNumber(pos);
			//mModel.setPromptNumber(peekNumberInStack);
			mModel.getPromptText().setTokens(peekNumberInStack.getTokens());
		}
		return false;
	}

	@Override
	public boolean undo() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public ICommand createNewInstance() {
		return new PeekCommand(mModel);
	}

}
